var stat = {
		//矿池统计
		pool:{
			page:0,
			size:20,
			//初始化
			init:function(coinType){
				stat.pool.getFoundBlocks(stat.pool.page,stat.pool.size,coinType);
				
				//绑定翻页事件
				$(".pageDiv").on("click","li",function(){
					var number = $(this).attr("page");
					if("<"==number){
						stat.pool.page = parseInt(stat.pool.page)-1;
					}else if(">"==number){
						stat.pool.page = parseInt(stat.pool.page)+1;
					}else{
						stat.pool.page = parseInt(number);
					}
					stat.pool.getFoundBlocks(stat.pool.page,stat.pool.size);

				});
				
			},
			getFoundBlocks:function(page,size,coinType){
				//查询统计列表
				$.post("/stat/foundBlocks",{
					page:stat.pool.page,
					size:stat.pool.size,
					coinType:coinType
				},function(data){
					if(data.code=='200'){
						var html = "";
						$.each(data.data.content,function(i,e){
							html+="<tr>";
							html+="<td class=\"font_eqwidthArea\">";
							html+="<a href=\"\" >"+e.height+"</a>";
							html+="</td>";
							html+="<td class=\"font_eqwidthArea\">"+new Date(e.createdAt).Format("yyyy-MM-dd hh:mm:ss")+"</td>";
							html+="<td class=\"font_eqwidth\">";
							html+="<a href=\"\">"+e.hash+"</a>";
							html+="</td>";
							html+="<td class=\"font_eqwidthArea\">";
							var re = parseFloat(e.rewards/100000000).toFixed(8);
							html+="<span class=\"tb_text_right_90\">"+re+"</span>";
							html+="</td>";
							html+="</tr>";
						});
						$(".pooltable table.blocks tbody").html(html);
						//总页数
						var totalPages = data.data.totalPages;
						var pageDivHtml =""; 
						if(totalPages<=10){
							for (var i = 1; i <= totalPages; i++) {
								if((i-1)==page){
									pageDivHtml+="<li page='"+(i-1)+"' class='current'><a>"+i+"</a></li>";
								}else{
									pageDivHtml+="<li page='"+(i-1)+"'><a>"+i+"</a></li>";
								}
							}
						}else{
							if(page>0){
								pageDivHtml+="<li page='0'><a >1</a></li>";
							}
							if(page>1){
								pageDivHtml+="<li page='<'><a >&lt;</a></li>";
							}
							if(parseInt(page)-2>0){
								pageDivHtml+="<li page='"+ (parseInt(page)-2)+"'><a >"+(parseInt(page)-1)+"</a></li>";
							}
							if(parseInt(page)-1>0){
								pageDivHtml+="<li page='"+parseInt(page-1)+"'><a >"+(page)+"</a></li>";
							}
							pageDivHtml+="<li page='"+page+"' class='current'><a >"+(parseInt(page)+1)+"</a></li>";
							if((parseInt(page)+1)<(parseInt(totalPages)-1)){
								pageDivHtml+="<li page='"+(parseInt(page)+1)+"'><a >"+(parseInt(page)+2)+"</a></li>";
							}
							if((parseInt(page)+2)<(parseInt(totalPages)-1)){
								pageDivHtml+="<li page='"+(parseInt(page)+2)+"'><a >"+(parseInt(page)+3)+"</a></li>";
							}
							if((parseInt(page)+2)<(parseInt(totalPages)-2)){
								pageDivHtml+="<li page='>'><a >&gt;</a></li>";
							}
							if((parseInt(totalPages)-1)>page){
								pageDivHtml+="<li page='"+(parseInt(totalPages)-1)+"'><a >"+totalPages+"</a></li>";
							}
						}
						$(".pageDiv").html(pageDivHtml);
					}
				},'json');
			}
		}
}